<template>
  <section class="carTypeConfig">
    <el-dialog
      v-dialogDrag
      title="来源字段"
      :visible.sync="curPopupsVisible"
      width="1000px"
      center
      @close="sendCode"
      :close-on-click-modal="false"
      :append-to-body="true"
    >
      <dialogHeader slot="title" :title="'来源字段'" :styleType="$store.state.app.dialogType"></dialogHeader>
      <one-table-template
        ref="multipleTable"
        :dynamicButtons="tableButtons"
        :dynamicComponents="tableComponents"
        :dynamicApiConfig="apiConfig"
        :dynamicTableCols="tableCols"
        :dynamicFormFields="formField"
        :dynamicIsShowSelect="false"
      />
    </el-dialog>
  </section>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
import { crmApis } from "@/api/apiList/crm";
import OneTableTemplate from "@/components/crm/commonComponents/crmPopupsOneTable";
export default {
  // 组件混入对象：{data[listQuery] methods[queryTable]}
  mixins: [oneTableWithViewTemplateMixins, valueObjectMixins],
  components: {
    OneTableTemplate,
    dialogHeader: () => import("@/components/dialogHeader") //弹窗标题
  },
  data() {
    return {
      // 网格查询API配置对象
      apiConfig: crmApis.crmDbFromFieldQueryFindAll,
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          clickEvent: () => this.queryTable(1),
          text: "查询",
          position: "top"
        },
        {
          compKey: "btnKey2",
          type: "primary",
          size: "small",
          clickEvent: () => this.sendCode(this.codeField, "fromFieldName"),
          text: "确认",
          position: "bottom"
        },
        {
          compKey: "btnKey3",
          type: "",
          size: "small",
          clickEvent: () => this.reset(),
          text: "重置",
          position: "top"
        }
      ],
      // 动态组件-查询条件
      tableComponents: [
        // 显示组件
        {
          compKey: "compKey1",
          labelName: "标签关系",
          codeField: "labelRelation",
          lookuptype: "LX846",
          component: () => import("@/components/crm/lookupValue/lookupvalue"),
          type: "dropdownList",
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey2",
          labelName: "来源数据表名称",
          codeField: "fromTableName",
          component: () => import("@/components/crm/textbox/crmTextInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey3",
          labelName: "来源字段名称",
          codeField: "fromFieldName",
          component: () => import("@/components/crm/textbox/crmTextInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey4",
          labelName: "是否启用",
          codeField: "isEnable",
          disabled: true,
          component: () => import("@/components/crm/Select/crmIsEnable"),
          type: "dropdownList",
          isMust: true
        }
      ],
      // 动态生成网格列
      tableCols: [
        {
          prop: "labelRelationName",
          label: "标签关系",
          width: null,
          align: "center"
        },
        {
          prop: "labelRelation",
          label: "标签关系",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "fromTableName",
          label: "来源数据表名称",
          width: null,
          align: "center"
        },
        {
          prop: "fromFieldId",
          label: "来源数据表名称",
          width: null,
          align: "center",
          hidden: true
        },

        {
          prop: "fromFieldName",
          label: "来源字段名称",
          width: null,
          align: "center"
        },
        {
          prop: "isEnable",
          label: "是否启用",
          width: null,
          align: "center"
        }
      ],
      //表单查询数据（查询条件）
      formField: {
        labelRelation: "",
        fromTableName: "",
        fromFieldName: "",
        isEnable: "1"
      },
            //双击事件
      handleTableRowData:{
        value:this.codeField,
        text:"fromFieldName"
      }
    };
  },
  mounted() {
    this.formField.isEnable = "1";
    this.$nextTick(() => {
      this.queryTable(1);
    });
  },
  methods: {
    //传递网格列数据
    getComponentCode(
      code,
      text,
      codeField,
      comType,
      popupsKey,
      textField,
      otherField,
      selectData
    ) {
      debugger;
      this.$emit("changeCode", selectData);
      this.$emit("getCode", selectData);
      this.modelText = text;
      this.curPopupsVisible = false;
    }
  }
};
</script>
